package com.edgar.protocol;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import java.nio.ByteBuffer;

/**
 * @author liqs
 * @version 1.0
 * @date 2020/12/30 11:38
 */
public class MyClientEncoder extends MessageToByteEncoder<ByteBuffer>{

    @Override
    protected void encode(ChannelHandlerContext ctx, ByteBuffer message, ByteBuf out)  {

        if(message==null){
            return;
        }
        if(message .hasArray()){
            byte[] msg =message.array();
            if(msg == null || msg.length <= 0){
                return;
            }
            out.writeBytes("test".getBytes());
        }
    }



}